<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>   13  Document</title>
    <script src="./js/vue.js"></script>
</head>
<body>

    <div id="app">


        
        <p>
            <button  v-for="(item,index) in list">{{item}}</button>
            
        </p>
        <p>
            求和  <span>{{total}}</span>
        </p>
        <p>
            <button @click="add">+</button>
        </p>
      
    </div>
    
</body>

<script>



    new Vue({
        el:"#app",
        data:{
            list:[1,2,3,4],

        },
        computed:{
            total(){
                return this.list.reduce((a,b) => a+b);
            }
        },
        methods:{
            add(){
                this.list.push(5)
            },
 
        }
    })
</script>
</html>